package com.netease.musicweekly.xml;

import java.io.IOException;

import org.xml.sax.SAXException;

import android.sax.EndTextElementListener;
import android.sax.RootElement;
import android.util.Xml;

import com.netease.musicweekly.entity.Article;

public class DocDetailParser extends BaseXMLParser {

	public Article getArticleInfo(String xml) throws XMLParseException,
			IOException, SAXException {
		final Article article = new Article();
		RootElement root = new RootElement("doc");
		root.getChild("title").setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String title) {
						article.title = title;
					}
				});
		root.getChild("body").setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String body) {
						article.body = body;
					}
				});
		root.getChild("source").setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String source) {
						article.source = source;
					}
				});
		root.getChild("date").setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String date) {
						article.date = date;
					}
				});
		Xml.parse(xml, root.getContentHandler());
		return article;
	} 

}
